package popup

import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.WindowManager
import android.widget.PopupWindow
import app.AppContext
import com.hontech.pizzav2.R


class SellPopupWindow {
    companion object {
        val Instance: SellPopupWindow by lazy { SellPopupWindow() }
        var isShow = false
    }

    private val mView = LayoutInflater.from(AppContext).inflate(R.layout.popup_sell, null)
    private val mPopupWindow = PopupWindow(
        mView, WindowManager.LayoutParams.MATCH_PARENT,
        WindowManager.LayoutParams.MATCH_PARENT, true
    )

    init {
        mPopupWindow.isOutsideTouchable = false
    }

    fun show(view: View) {
        if (isShow) return
        isShow = true
        mPopupWindow.showAtLocation(view, Gravity.CENTER, 0, 0)
    }

    fun dismiss() {
        if (!isShow) return
        mPopupWindow.dismiss()
        isShow = false
    }

}